<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.min.js"></script>
</head>
<body>
    <div id="app" class="parent">
        {{message}}
        <child @testcreated="oncreated" @testmounted="onmounted" @testupdated="onupdated"></child>
    </div>
<script>
  var app = new Vue({
        el: '#app',
        data: {
            message: '父组件'
        },
        components:{
            'child':{
                data:function () {
                    return {
                        childMessage: '子组件'
                    }
                } ,
                template: `<div>{{ childMessage}}</div>`,
                created(){ this.$emit('testcreated')},
                mounted(){this.$emit('testmounted')},
                updated(){this.$emit('testupdated')}
            }
        },
        created(){console.log("父created") ;this.message = "test"},
        mounted(){console.log("父mounted")},
        updated(){console.log("父updated")},
        methods:{
            oncreated(){console.log("子created")},
            onmounted(){console.log("子mounted")},
            onupdated(){console.log("子updated")},
        }

    })
</script>
</body>
</html>